package org.shagin.jfin.sheet;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * The Class SheetData.
 */
public class SheetData {

	private List<SheetColumn<?>> columns = new ArrayList<SheetColumn<?>>();

	private List<SheetRow> rows = new ArrayList<SheetRow>();

	/**
	 * Instantiates a new sheet data.
	 */
	public SheetData() {
	}

	/**
	 * Gets the columns.
	 *
	 * @return the columns
	 */
	public List<SheetColumn<?>> getColumns() {
		return Collections.unmodifiableList(columns);
	}

	/**
	 * Gets the rows.
	 *
	 * @return the rows
	 */
	public List<SheetRow> getRows() {
	    // TODO Optimize performance
		return Collections.unmodifiableList(rows);
	}

	/**
	 * Adds the column.
	 *
	 * @param col the col
	 */
	public void addColumn(SheetColumn<?> col) {
		columns.add(col);
	}

	/**
	 * Adds the row.
	 *
	 * @param row the row
	 */
	public void addRow(SheetRow row) {
		rows.add(row);
	}

	/**
	 * Gets the column index.
	 *
	 * @param col the col
	 * @return the column index
	 */
	public int getColumnIndex(SheetColumn<?> col) {
		return columns.indexOf(col);
	}

	/**
	 * Gets the column.
	 *
	 * @param index the index
	 * @return the column
	 */
	public SheetColumn<?> getColumn(int index) {
		return columns.get(index);
	}

	/**
	 * Gets the row index.
	 *
	 * @param row the row
	 * @return the row index
	 */
	public int getRowIndex(SheetRow row) {
		return rows.indexOf(row);
	}

	/**
	 * Gets the row.
	 *
	 * @param index the index
	 * @return the row
	 */
	public SheetRow getRow(int index) {
		return rows.get(index);
	}

	/**
	 * Gets the row count.
	 *
	 * @return the row count
	 */
	public int getRowCount() {
		return rows.size();
	}

	/**
	 * Gets the column count.
	 *
	 * @return the column count
	 */
	public int getColumnCount() {
		return columns.size();
	}

}
